// @FileName  :replace.c
// @Time      :2024/3/7 10:35
// @Author    :YKW
//# include <bits/stdc++.h>
//using namespace std;
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <string.h>
# include <stdlib.h>

void main() {
    char st[10086], end[10086], str[10086], str2[10086];
    gets(st);
    gets(end);
    freopen("filein.txt", "r", stdin);
    freopen("fileout.txt", "w", stdout);
    while (gets(str) != NULL) {
        strcpy(str2, str);
        char *h = str, *s = st;
        while (*h != '\0') {
            if (*h <= 'Z' && *h >= 'A')
                *h = *h - 'A' + 'a';
            h++;
        }
        while (*s != '\0') {
            if (*s <= 'Z' && *h >= 'A')
                *s = *s - 'A' + 'a';
            s++;
        }
        h = str;
        while (*h != '\0') {
            if (h == strstr(h, st)) {
                printf("%s", end);
                h += strlen(st);
            } else {
                printf("%c", str2[h - str]);
                h++;
            }
        }
        puts("");
    }
}